package com.hdu.dwh.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

import org.springframework.stereotype.Component;

import com.hdu.dwh.utils.TrinoQueryUtils;

import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Data
public class TrinoDao {
    private final Connection trinoConnection;

    private Connection connection;

    // public TrinoDao() throws SQLException {
    //     String url = trinoConfig.getUrl();1
    //     Properties properties = new Properties();
    //     properties.setProperty("user", "admin");
    //     properties.setProperty("SSL", "false");
    //     this.connection = DriverManager.getConnection(url, properties);
    //     log.info("Trino JDBC连接成功");
    // }

    // public String getTrinoUrl() {
    //     return trinoConfig.getUrl();
    // }

    public ResultSet executeQuery(Statement statement, String sql) throws SQLException{
        try {
            return statement.executeQuery(sql);
        } catch (SQLException e) {
            e.printStackTrace();
            throw e;
        }
    }

    public Statement createStatement(Connection connection) throws SQLException {
        return connection.createStatement();
    }

    public Connection gettConnection() {
        return this.connection;
    }
}
